package cn.wangyu.msblogadmin.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 跨域配置
 *
 * @author wangyu
 * @version 1.0
 * @date 2021/5/6 0:15
 */
@Configuration
public class CorsConfig implements WebMvcConfigurer {

    static final String[] ORIGINS = new String[] { "GET", "POST", "PATCH","PUT", "DELETE" };

    @Override
    public void addCorsMappings(CorsRegistry registry) {
        registry.addMapping("/**").allowedOrigins("*").allowCredentials(true).allowedMethods(ORIGINS).maxAge(3600);
    }
}
